/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sociesc.indoorgps.utils;

import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.sociesc.indoorgps.User;
import com.sociesc.indoorgps.dao.ConnectionFactory;
import com.sociesc.indoorgps.dao.Dao;
import java.sql.SQLException;

public class DatabaseUtils {
    
    public static void createDatabase() throws SQLException{
        ConnectionSource conn = ConnectionFactory.createConn();
        TableUtils.createTableIfNotExists(conn, User.class);
        conn.close();
    }
    
    public static void seedDatabase() throws SQLException{
        DatabaseUtils.createDatabase();
        Dao<User> userDao = new Dao(User.class);
        String name = "Zezinho";
        User user = new User(name);
        userDao.create(user);
        
    }
    
}
